<template>
  <el-dialog
    v-el-drag-dialog
    title="库存结转"
    :visible.sync="isShow"
    width="500px"
    class="stockCarriedForward-AddDialog"
    @closed="reset"
  >
    <el-form
      ref="formRef"
      class="form"
      :model="form"
      :rules="rules"
      label-position="right"
      label-width="100px"
    >
      <el-form-item label="结转仓库" prop="storeId">
        <el-select
          v-model="form.storeId"
          style="width: 100%;"
          placeholder="请选择结转仓库"
        >
          <el-option
            v-for="item in storeMap"
            :key="item.storeId"
            :label="item.storeName"
            :value="item.storeId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="结转时间" prop="happendDt">
        <el-date-picker
          v-model="form.happendDt"
          style="width: 100%;"
          type="datetime"
          placeholder="选择日期时间"
          :picker-options="pickerOptions"
        />
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button type="primary" @click="save"> 保存 </el-button>
      <el-button @click="reset"> 关闭 </el-button>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    props: ['storeMap'],
    data() {
      return {
        isShow: false,
        form: {
          storeId: '',
          happendDt: '',
          orgId: ''
        },
        rules: {
          happendDt: [{ required: true, message: '请选择结转时间', trigger: 'change' }],
          storeId: [{ required: true, message: '请选择结转仓库', trigger: 'change' }]
        },
        pickerOptions: {
          disabledDate: (date) => {
            return new Date(date) > new Date()
          }
        }
      }
    },
    methods: {
      show() {
        this.isShow = true
      },
      reset() {
        this.$refs.formRef.resetFields()
        this.isShow = false
      },
      save() {
        this.$refs['formRef'].validate((valid) => {
          if (valid) {
            this.saveSubmit()
          } else {
            return false
          }
        })
      },
      saveSubmit() {}
    }
  }
</script>

<style lang="scss" scoped></style>
